package v1

import (
	"github.com/go-gormigrate/gormigrate/v2"
	"gorm.io/gorm"
)

// 本迁移文件是一些 demo 示例，和项目无关

// ResizeListContentField User v1 Migration
var ResizeListContentField = gormigrate.Migration{
	ID: "v1.ResizeListContentField",
	Migrate: func(tx *gorm.DB) error {
		// when table already exists, it just adds fields as columns
		type YouduJielongLists struct {
			Content string `gorm:"type:varchar(4096);"`
		}
		// NOTE(fanguiju): 这里可以选择使用 DDL 语句或 AutoMigrate 功能。
		return tx.Migrator().AlterColumn(&YouduJielongLists{}, "Content")
	},
	Rollback: func(tx *gorm.DB) error {
		type YouduJielongLists struct {
			Content string `gorm:"type:varchar(1024);"`
		}
		return tx.Migrator().AlterColumn(&YouduJielongLists{}, "Content")
	},
}
